package it.hive.controller.listener;

import it.hive.mediaplayer.properties.MediaPlayerProperties;
import it.hive.model.common.ApplicationProperties;
import javafx.scene.media.AudioSpectrumListener;

public class AudioVisualizer implements AudioSpectrumListener {

	@Override
	public void spectrumDataUpdate(double timestamp, double duration, float[] magnitudes, float[] phases) {
		if (ApplicationProperties.animazioneAudioAbilitata.get()) {
			ApplicationProperties.rightAudio.set(MediaPlayerProperties.volumeProperty.multiply(
					(magnitudes[2] + 60.0) * ApplicationProperties.livelloAnimazioneAudio.get()).doubleValue());
			ApplicationProperties.leftAudio.set(MediaPlayerProperties.volumeProperty.multiply(
					(magnitudes[3] + 60.0) * ApplicationProperties.livelloAnimazioneAudio.get()).doubleValue());
		}
	}
}
